<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮询</title>
</head>
<body>
<div id="clock">

</div>
<script>
  const clock = document.querySelector('#clock');

  setInterval(function () {
    const xhr = new XMLHttpRequest();
    xhr.open('GET', '/clock', true);
    xhr.onreadystatechange = function () {
      if (xhr.readyState == 4 && xhr.status == 200) {
        clock.innerHTML = xhr.responseText;
      }
    };
    xhr.send();
  }, 1000);

  function send(){}
</script>
</body>
</html>
